// K&R book. p36.

#include <stdio.h>
#include <stdlib.h>

unsigned long int nex;

int randx(void);
void srandx(unsigned int seed);

int main()
{
    unsigned int seed;

    seed = 1;

    srandx(seed);
    printf("randx Number is %d\n", randx());
    printf("rand Number is %d\n", rand());

    return 0;
}

int randx(void)
{

    nex = nex * 1103515245 + 12345;

    return (unsigned int)(nex / 65526) % 32768;
}

void srandx(unsigned int seed)
{
    nex = seed;
}
